/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.TaskCategoryManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class AddTaskCategory extends AbstractAction
/*    */ {
/* 24 */   private static Logger logger = Logger.getLogger(AddTaskCategory.class
/* 25 */     .getName());
/*    */ 
/*    */   public AddTaskCategory(AbstractHttpServlet servlet)
/*    */   {
/* 28 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 34 */     User user = super.getLoginUser(request);
/* 35 */     response.setContentType("text/html;charset=utf-8");
/* 36 */     PrintWriter out = response.getWriter();
/*    */ 
/* 38 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 40 */     if (!user.isAdmin) {
/* 41 */       jsonObject.put("error", "0");
/* 42 */       out.println(jsonObject);
/* 43 */       out.flush();
/* 44 */       out.close();
/* 45 */       return;
/*    */     }
/*    */ 
/* 48 */     String name = 
/* 49 */       Util.getURLParameter(request.getParameter("categoryName"));
/* 50 */     TaskCategoryManager manager = new TaskCategoryManager();
/*    */     try {
/* 52 */       int id = manager.add(user.companyId, name, user.userId);
/* 53 */       CompanyInfo company = super.getCompany(user.companyId);
/* 54 */       company.taskCategorys = manager.list(user.companyId);
/* 55 */       jsonObject.put("error", "0");
/* 56 */       jsonObject.put("taskCategoryId", Integer.valueOf(id));
/*    */     } catch (Exception e) {
/* 58 */       jsonObject.put("error", "1");
/* 59 */       logger.warn("add task category failed", e);
/*    */     }
/*    */ 
/* 62 */     out.println(jsonObject);
/* 63 */     out.flush();
/* 64 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.AddTaskCategory
 * JD-Core Version:    0.6.1
 */